<template>
  <div>
    <!-- 个人信息 -->
    <el-row>
      <el-col :span="24" style="padding: 40px;">
        <el-card style="margin:0 auto;">
          <div slot="header">
            <span style="font-size: 25px;">个人信息</span>
          </div>
          <div style="margin-top: 23px;">
            <div>
              <span style="color: rgb(139, 138, 138);">用户ID：</span>
              <span >{{user_info.id}}</span>
            </div>
            <el-divider></el-divider>
            <div>
              <span style="color: rgb(139, 138, 138);">昵称：</span>
              <span >{{user_info.nickname}}</span>
            </div>
            <el-divider></el-divider>
          </div>
        </el-card>
      </el-col>

    </el-row>
    <el-row>
      <!-- 我的模型 -->
      <el-col :span="24" style="padding: 40px;">
        <el-card  style="margin:0 auto;">
          <div slot="header">
            <span style="font-size: 25px;">我的模型</span>
          </div>
          <div class="text item">
            <span style="color: rgb(139, 138, 138);">模型类型：</span>
            <span>{{ model_info.model_type }}</span>
          </div>
          <el-divider></el-divider>
          <div>
            <span style="color: rgb(139, 138, 138);">模型结构：</span>
            <span>{{ model_info.model_struct}}</span>
          </div>
          <el-divider></el-divider>
          <div>
            <span style="color: rgb(139, 138, 138);">激活函数：</span>
            <span>{{ model_info.activation}}</span>
          </div>
          <el-divider></el-divider>
          <div>
            <span style="color: rgb(139, 138, 138);">模型准确率：</span>
            <span>{{ model_info.accuracy}}</span>
          </div>
          <el-divider></el-divider>
          <div>
            <span style="color: rgb(139, 138, 138);">模型训练时间：</span>
            <span>{{ model_info.train_consume}}</span>
          </div>
          <el-divider></el-divider>
          <div>
            <el-button @click="switchTest" multiple = "multiple" type="primary">点击测试模型</el-button>
          </div>
        </el-card>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-button class="logoutBtn" type="danger" @click="logoutLogin">注销登录</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
const axios = require('axios');
export default {
  name: "UserInfo",
  data() {
    return {
      user_info:{
        id:"",
        nickname:""
      },
      model_info:{
        model_struct:"",
        model_type:"",
        activation:"",
        accuracy: "",
        train_consume: ""
      }
    }
  },
  methods: {
    switchTest(){
      this.$router.push({path:"/modeleva"})
    },
    logoutLogin(){
      var _this=this
      //注销登录
      if(confirm("确认要注销当前用户吗")){
        axios.get("http://192.168.31.103:2444/LoginCenter/userlogout").then(function(res){
          _this.$router.push({path:"/login"})
        });
      }
    }
  },
  mounted() {
    var _this=this
    axios.get("http://192.168.31.103:2444/LoginCenter/getUserInfo").then(function(res){
      console.log(res)
      _this.$data.user_info.id=res.data.user_id;
      _this.$data.user_info.nickname=res.data.nickname;
      if(res.data=="")  _this.$router.push({path:"/login"})
      else{
        _this.$data.user_info.id=res.data.user_id;
        _this.$data.user_info.nickname=res.data.nickname;
      }
    });
    axios.get("http://192.168.31.103:2444/ModelCenter/getMyModelInfo").then(function(res){
      console.log(res)
      _this.$data.model_info.model_struct=res.data.model_struct;
      _this.$data.model_info.model_type=res.data.model_type;
      _this.$data.model_info.activation=res.data.activation;
      _this.$data.model_info.accuracy=res.data.accuracy + '%';
      _this.$data.model_info.train_consume=res.data.train_consume + '分';
    })
  }
}
</script>

<style scoped>

</style>
